package com.testmanager.testmananger.practiseDemo.dataCreateProvide;


import com.testmanager.testmananger.foundation.util.FlakeIdGenerator;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class MobileService {

    @Autowired
    MobileRepository mobileRepository;

    @Autowired
    FlakeIdGenerator flakeIdGenerator;
    public ResponseEntity save(MobileEntity mobileEntity){
        try {
            log.info("save mobileEntity:{}",mobileEntity);

           mobileEntity.setId(flakeIdGenerator.newId());


            MobileEntity entity = mobileRepository.save(mobileEntity);
            return ResponseEntity.ok(entity);
        }catch (Exception e){
            return ResponseEntity.status(500).body(e);
        }



    }



}
